#include <stdio.h>
#include <string.h>
int main ()
{
    int n,num,j,fir,sec,thi,ave;
    char a[100][100];
    printf("Please input the number of students you should input:\n");
    scanf("%d",&n);

    for (int i=0;i<n;i++)
    {
        printf("Please input the %d  student information: student number, the first grade ,the second ,the third.\n",i+1);
        scanf("%d%d%d%d",&num,&fir,&sec,&thi);
        ave=(fir+sec+thi)/3;
       
       sprintf(a[i],"%d %d %d %d %d",num,fir,sec,thi,ave);
       printf("%s\n",a[i]);
    }
    FILE *fp=fopen("C:\\Users\\lenovo\\Desktop\\stud.csv","w");
    if(fp== NULL)
    {
        printf("文件打开失败\n");
    }
    for(int j=0;j<n;j++)
    {
        fputs(a[j],fp);
        fputs("\n",fp);
    }
        fclose(fp);

    return 0;
}